Preserve PR description when branch push fails during PR creation#8713
Merged
Conversation
Agent-Logs-Url: https://github.com/microsoft/vscode-pull-request-github/sessions/c8e1de78-c793-4ee5-adb0-4c897e9af93d Co-authored-by: alexr00 <38270282+alexr00@users.noreply.github.com>
Copilot
AI
changed the title
[WIP] Fix PR description reset if branch push fails
Preserve PR description when branch push fails during PR creation
Apr 28, 2026
alexr00
approved these changes
May 4, 2026
alexr00
approved these changes
May 5, 2026
Contributor
There was a problem hiding this comment.
Pull request overview
This PR fixes a state persistence bug in the “Create PR” webview where a failed PR creation attempt (e.g., push rejected due to needing --force) could cause the user’s typed title/description to be overwritten by the PR template when the webview reloads from persisted state.
Changes:
- Delays clearing the webview’s persisted
vscodestate until after thepr.createrequest completes successfully, so failures retain the user-entered title/description. - Adds an inline rationale comment documenting the failure/reload scenario that motivated the change.
Show a summary per file
| File | Description |
|---|---|
| webviews/common/createContextNew.ts | Moves persisted-state reset to after the pr.create round-trip to preserve user-entered text across reloads when creation fails. |
Copilot's findings
- Files reviewed: 1/1 changed files
- Comments generated: 0
hediet
approved these changes
May 5, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
When the create-PR flow failed (e.g. an amended commit requires
--forcepush), the user's typed title and description were silently replaced with the PR template the next time the webview re-rendered from persisted state.Root cause
submit()inwebviews/common/createContextNew.tscleared the persisted webview state before awaitingpr.create:On failure, the in-memory
catchsetcreateError, but the persisted state was already gone. Since the create view doesn't useretainContextWhenHidden, hiding/reopening the panel reloaded the webview fromvscode.getState(), andhandleMessage('pr.initialize')then fell back todefaultDescriptionbecausependingDescriptionwasundefined— restoring the template over the user's text.Change
vscode.setState(defaultCreateParams)to after the awaitedpr.createround-trip insubmit(). Reset only happens on success; on failure the user's title/description remain in persisted state alongside the newcreateError.Cleanup on success paths is unchanged:
_firstLoadreset and the'reset'message dispatched fromdispose()still clear state when the view is reopened.